<!--Descriptive page name, messages and instructions-->
<h2 id='upload-heading'><%=h t('.works.import', :default => 'Import New Work') %></h2>
<%= error_messages_for :work %>
<!--/descriptions-->

<ul class="navigation">
  <% if @unposted %>
    <li id='restore-link'>
      <%= link_to 'Restore From Last Unposted Draft?', url_for(:action => :new, :load_unposted => true) %>
    </li>
  <% end %>
  <li id="form-link">
     <%= link_to( t('.standard', :default => 'Post New Work Instead?'),
       {:url => {:controller => :works, :action => :new, :import => false}},
       :href => url_for(:controller => :works, :action => :new, :import => false)) %>
  </li>
</ul>

<!-- This partial renders a form for importing a work from an existing URL -->
<div class="clear"<!--purely presentational, phase me out--></div>
<p class="message">
  <strong><%= t('.import.please_note', :default => 'Please note!') %></strong> 
  <%= t('.import_problems', :default => 'We cannot always automatically import works.') %> If you have trouble, <%= link_to t('.let_us_know', :default => "please let us know"), new_feedback_report_path %> so we can improve this tool!</p> 
  
  <ul>
    <li>If your text gets truncated at the point of an em dash or accented character, you might have to manually set the encoding in the text field below.</li>
    <li>If you are importing a chaptered work from ff.net, you only need to enter the URL of the first chapter. However, currently you cannot turn multiple ff.net works into the chapters of a single work.</li>
    <li>Unless you check the override box, any information you enter under Work Tags will only be used if the importer cannot determine tags from the work itself.</li>
    <li>You will be able to edit and complete the standard header information after the import has been completed.</li>
  </ul>
  
<%= form_tag url_for(:controller => :works, :action => :import) do %>
<fieldset>
  <legend><%= "Works URLs" %></legend>
  <p>
    <%= label_tag "urls", t('.import.url', :default => 'URLs for existing work(s) or for the chapters of a single work, one URL per line:') %> <br />
    <%= text_area_tag "urls", @urls ? @urls.join("\n") : "", :rows => 20, :cols => 90 %>
  </p>
  
  <p>
    <%= label_tag "encoding", ts("Set custom encoding to overwrite automatic detection: ") %> 
    <%= text_field_tag "encoding" %> <%= link_to_help "encoding-help" %>
    <%= autocomplete_text_field "encoding", :no_comma => true %> 
  </p>
  
  <p>
    <%= radio_button_tag "import_multiple", "works", true %>
    <%= label_tag "import_multiple_works", t('.import.works', :default => "Works (limit of %{max})", :max => current_user.archivist ? ArchiveConfig.IMPORT_MAX_WORKS_BY_ARCHIVIST : ArchiveConfig.IMPORT_MAX_WORKS) %>
    <br />
    <%= radio_button_tag "import_multiple", "chapters" %>
    <%= label_tag "import_multiple_chapters", t('.import.chapters', :default => "Chapters in a single work (limit of %{max})", :max => ArchiveConfig.IMPORT_MAX_CHAPTERS) %>
  </p>
  
  <% if current_user.archivist %>
  <p>
    <%= check_box_tag "importing_for_others" %>
    <%= label_tag "importing_for_others", t('.import.for_others', :default => "Import works for others (ONLY WITH PERMISSION)") %>
  </p>
  <% end %>

  <p>
    <%= check_box_tag "post_without_preview" %>
    <% if current_user.archivist %>
      <%= label_tag "post_without_preview", t('.import.without_preview_by_archivist', :default => "Post without previewing (STRONGLY recommended if importing for others!)") %>
    <% else %>
      <%= label_tag "post_without_preview", t('.import.without_preview', :default => "Post without previewing.") %>
    <% end %>
  </p>

  <p>
    <%= check_box_tag "restricted" %>
    <%= label_tag "restricted", ts("Lock all imported stories to registered users only.") %>
  </p>

  <p>
    <%= check_box_tag "override_tags" %>
    <%= label_tag "override_tags", ts("Set the tags below on all stories, overriding whatever the importer finds.") %>
  </p>

  <div id="work-form" class="work-form"><%= render :partial => 'work_tags_form', :locals => {:include_blank => true} %></div>

</fieldset>


<fieldset>
	<legend><%= "Submit" %></legend>
  <p class="submit">
  <%= submit_tag t('.import.import_story', :default => 'Import') %>
  </p>
</fieldset>

<% end %>
